package org.darack_application;

import android.app.*;
import android.app.AlertDialog.Builder;
import android.content.*;
import android.graphics.drawable.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.widget.TabHost.OnTabChangeListener;

public class MainActivity extends TabActivity implements OnTabChangeListener{
	TabHost mTab;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		TabHost tabHost = getTabHost();
		
		Drawable icon1 = getResources().getDrawable(R.drawable.notice);
		Drawable icon2 = getResources().getDrawable(R.drawable.notepad);
		Drawable icon3 = getResources().getDrawable(R.drawable.notepad);
		Drawable icon4 = getResources().getDrawable(R.drawable.personal);
				
		tabHost.addTab(tabHost.newTabSpec("notice").setIndicator("공지사항",icon1).setContent(new Intent(this,NoticeActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
		tabHost.addTab(tabHost.newTabSpec("enrolled").setIndicator("재학생 게시판",icon2).setContent(new Intent(this,EnrolledActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
		tabHost.addTab(tabHost.newTabSpec("graduate").setIndicator("졸업생 게시판",icon3).setContent(new Intent(this,GraduateActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
		tabHost.addTab(tabHost.newTabSpec("contact").setIndicator("주소록",icon4).setContent(new Intent(this,ContactsDBListActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
		
	}
	@Override
	public void onTabChanged(String tabId) {
		
	}
	
	public void onBackPressed() {
		
		Builder d = new AlertDialog.Builder(this);
		d.setMessage("정말 종료하시겠습니까?");
		d.setPositiveButton("예", new DialogInterface.OnClickListener() {

			public void onClick(DialogInterface dialog, int which) {
				finish();
			}
		});
		d.setNegativeButton("아니요", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				dialog.cancel();
			}
		});
		d.show();
	} 
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.menu_main, menu);
		return true;
	}
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.about:
			Intent intent = new Intent(this, MenuAboutActivity.class);
			startActivity(intent);
			return true;
		}
		return false;
	}
	
}
